package com.bigflexlib.x.flash.filesystem
{
	
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	
	
	/**
	 * 
	 * Common sync reading snippets.
	 * 
	 * @author aldo.bucchi@gmail.com
	 * 
	 */	
	public class FileReadingUtil
	{
		
		public static function readFile(file:File):String
		{
			var stream:FileStream = new FileStream();
			stream.open(file, FileMode.READ);
			var contents:String = stream.readUTFBytes(stream.bytesAvailable);
			stream.close();
			return contents;
		}		
	
		public static function readXML( file:File ):XML
		{
	        var str:String = readFile( file ).replace( File.lineEnding, "\n" );
			var xml:XML = new XML( str );		
			return xml;		
		}	

	}
	
}